      <div class="templatemo-content-wrapper">
        <div class="templatemo-content">
        <ul class="nav nav-tabs mytabs">
		  <li  class="active"><a href="<?=site_url()?>/staff/index">员工列表</a></li>
		  <li role="presentation"><a href="<?=site_url()?>/staff/add"><i class="fa fa-plus"></i> 添加员工</a></li>
		</ul>
         <div class="row margin-bottom-30">
            <div class="col-md-12">
            	<input type="text" id="name" name="name" value="">
            	<select id="department">
            		<option value="0">职位</option>
                   	<?php foreach ($departments as $item):?>
                    	<option value="<?php echo $item['id'];?>" <?php if($item['id'] ==$department) echo "selected"; ?>><?php echo $item['name'];?></option>
                    <?php endforeach;?>
            	</select>
            	<select id="type">
            		 <option value="-1" <?php if($type==-1) echo "selected"; ?>>全部</option>
                     <option value="0" <?php if($type==0) echo "selected"; ?>>全职</option>
            		 <option value="1" <?php if($type==1) echo "selected"; ?>>兼职</option>
            	</select>
            	<select id="security">
            		 <option value="-1" <?php if($security==-1) echo "selected"; ?>>全部</option>
                     <option value="0" <?php if($security==0) echo "selected"; ?>>缴纳社保</option>
            		 <option value="1" <?php if($security==1) echo "selected"; ?>>不缴纳社保</option>
            	</select>
            	<select id="fund">
            		 <option value="-1" <?php if($fund==-1) echo "selected"; ?>>全部</option>
                     <option value="0" <?php if($fund==0) echo "selected"; ?>>缴纳公积金</option>
            		 <option value="1" <?php if($fund==1) echo "selected"; ?>>不缴纳公积金</option>
            	</select>
            	<select id="state">
            		 <option value="-1" <?php if($state==-1) echo "selected"; ?>>全部</option>
                     <option value="1" <?php if($state==1) echo "selected"; ?>>实习期</option>
            		 <option value="2" <?php if($state==2) echo "selected"; ?>>入职</option>
            		 <option value="3" <?php if($state==3) echo "selected"; ?>>离职</option>
            	</select>
            	<button class="btn btn-primary" id="submit_btn">搜索</button>
              	<a class="btn btn-primary" id="order_btn" href="<?php echo site_url('staff/export')?>">导出到EXCEL</a>
            </div>
          </div> 
          <div class="row">
            <div class="col-md-12">
             <!-- <div class="btn-group pull-right" id="templatemo_sort_btn">
                <button type="button" class="btn btn-default">Sort by</button>
                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                  <span class="caret"></span>
                  <span class="sr-only">Toggle Dropdown</span>
                </button>
                <ul class="dropdown-menu" role="menu">
                  <li><a href="#">First Name</a></li>
                  <li><a href="#">Last Name</a></li>
                  <li><a href="#">Username</a></li>
                </ul>
             </div>-->
              
              <div class="table-responsive">
                
                <table class="table table-striped table-hover table-bordered">
                  <thead>
                    <tr>
                      <th>ID</th>
                      <th width="6%">姓名</th>
                      <th>性别</th>
                      <th>身份证号码</th>
                      <th>出生日期</th>
                      <th>学历</th>
                      <th width="10%">住址</th>
                      <th width="4%">类型</th>
                      <th>银行卡号</th>
                      <th>手机号码</th>
                      <th>薪水</th>
                      <th>职位</th>
                      <th>是否缴纳社保</th>
                      <th>是否缴纳公积金</th>
                      <th>是否缴纳商保</th>
                      <th>职位状态</th>
                      <th>入职时间</th>
                      <th>离职时间</th>
                      <th width="8%">操作</th>
                    </tr>
                  </thead>
                  <tbody>
                  	<?php foreach ($staffs as $item):?>
                    <tr>
                      <td><?php echo $item['id'];?></td>
                      <td><?php echo $item['name'];?></td>
                      <td><?php 
                      	if($item['gender']==0){
                      		echo "男";
                      	}
                      	if($item['gender']==1){
                      		echo "女";
                      	}
                      ?></td>
                      <td><?php echo $item['idcard'];?></td>
                      <td><?php echo $item['birthday'];?></td>
                      <td><?php echo $item['degree'];?></td>
                      <td><?php echo $item['address'];?></td>
                       <td><?php 
                      	if($item['type']==0){
                      		echo "全职";
                      	}
                      	if($item['type']==1){
                      		echo "兼职";
                      	}
                      ?></td>
                      <td><?php echo $item['bankcard'];?></td>
                      <td><?php echo $item['phone'];?></td>
                      <td><?php echo $item['salary'];?></td>
                      <td><?php echo $item['dname'];?></td>
                      <td><?php 
                      	if($item['security']==0){
                      		echo "是";
                      	}
                      	if($item['security']==1){
                      		echo "否";
                      	}
                      ?></td>
                      <td><?php 
                      	if($item['fund']==0){
                      		echo "是";
                      	}
                      	if($item['fund']==1){
                      		echo "否";
                      	}
                      ?></td>
                        <td><?php 
                      	if($item['insurance']==0){
                      		echo "是";
                      	}
                      	if($item['insurance']==1){
                      		echo "否";
                      	}
                      ?></td>
                       <td><?php 
                      	if($item['state']==1){
                      		echo "实习期";
                      	}
                      	if($item['state']==2){
                      		echo "入职";
                      	}
						if($item['state']==3){
                      		echo "离职";
                      	}
                      ?></td>
                      <td><?php echo $item['start_date'];?></td>
                      <td><?php echo $item['end_date'];?></td>
                      <td>
                      	   <a href="<?php echo site_url('staff/edit/id/'.$item['id'])?>" class=" ">编辑</a>                    
                      	   | <a href="#" class="del" data-id="<?php echo $item['id'];?>" >删除</a>
                      </td>
                    </tr>
                     <?php endforeach;?>
                  </tbody>
                </table>
              </div>
              <!--<ul class="pagination pull-right">
                <li class="disabled"><a href="#">&laquo;</a></li>
                <li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">2 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">3 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">4 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">5 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">&raquo;</a></li>
              </ul>  -->
            </div>
          </div>
           <div class="pagination">
            <?php echo $links ;?>
          </div>
        </div>
      </div>
    <script>
	$(document).ready(function() {
		$("#submit_btn").click(function() {
			var name = $("#name").val();
			var department = $("#department").val();
			var type = $("#type").val();
			var security = $("#security").val();
			var fund = $("#fund").val();
			var state = $("#state").val();
			if(name==""||name==null){
				name="empty";
			}
			var url = "<?php echo site_url('staff/index')?>";
			window.location.href=url+"/name/"+name+"/department/"+department+"/type/"+type+"/security/"+security+"/fund/"+fund+"/state/"+state;
		});
		$("#name").keydown(function(e) {
			if(e.keyCode == 13) {
				var name = $("#name").val();
				var department = $("#department").val();
				var type = $("#type").val();
				var security = $("#security").val();
				var fund = $("#fund").val();
				var state = $("#state").val();
				if(name==""||name==null){
					name="empty";
				}
				var url = "<?php echo site_url('staff/index')?>";
				window.location.href=url+"/name/"+name+"/department/"+department+"/type/"+type+"/security/"+security+"/fund/"+fund+"/state/"+state;
			}
		});
		$(".del").click(function() {
			if(confirm("确定要删除该员工吗？"))
			{
			var id = $(this).attr("data-id");
			$.ajax({
				url : '<?php echo site_url('staff/delete')?>',
				type : "post",
				async : true,
				data : {
					'id' : id
				},
				dataType : "json",
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
						window.location.reload();
					}else{
						alert(data.msg);
					}
					
				}
			});
			}
		});
	}); 
</script>